---
image: /generated/articles-docs-studio-watch-public-folder.png
title: watchPublicFolder()
crumb: "@remotion/studio"
---

# watchPublicFolder()<AvailableFrom v="4.0.154"/>

Watches for changes in the [public directory](/docs/terminology/public-dir) and calls a callback function when a file is added, removed or modified.

:::note
This feature is only available within the Remotion Studio environment. In the Player, events will never fire.
:::

## Example

```tsx twoslash title="example.tsx"
import { StaticFile, watchPublicFolder } from "@remotion/studio";

// Watch for changes in a specific static file
const { cancel } = watchPublicFolder((newFiles: StaticFile[]) => {
  console.log("The public folder now contains:", newFiles);
});

// To stop watching for changes, call the cancel function
cancel();
```

## Arguments

Takes one argument and returns a function that can be used to `cancel` the event listener.

### `callback`

A callback function that will be called when the directory is modified. As an argument, an array of [`StaticFile`](/docs/getstaticfiles#api)'s is passed.

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/watch-public-folder.ts)
- [`watchStaticFile()`](/docs/studio/watch-static-file)
- [`staticFile()`](/docs/staticfile)
- [`getStaticFiles()`](/docs/studio/get-static-files)
